import { reactive } from 'vue';

export default function importConfig() {
  const base = reactive<any>({
    size: 'medium',
    columns: [],
    searchConfig: null,
    config: [],
    pagination: {
      defaultPageSize: 10,
      total: 2, //总条数
      current: 1,
      pageSize: 10,
      showTotal: true,
      showPageSize: true,
      pageSizeOptions: [10, 20, 30, 40, 50],
    },
    loading: true,
  });

  const data = [
    {
      COMPANY: 'COMPANY',
      CREATOR: 'CREATOR',
      MA001: 'MA001',
      MA002: 'MA002',
      MA003: 'MA003',
      MA011: 'MA011',
      MA012: 'MA012',
      MA013: 'MA013',
    },
    {
      COMPANY: 'COMPANY',
      CREATOR: 'CREATOR',
      MA001: 'MA001',
      MA002: 'MA002',
      MA003: 'MA003',
      MA011: 'MA011',
      MA012: 'MA012',
      MA013: 'MA013',
    },
    {
      COMPANY: 'COMPANY',
      CREATOR: 'CREATOR',
      MA001: 'MA001',
      MA002: 'MA002',
      MA003: 'MA003',
      MA011: 'MA011',
      MA012: 'MA012',
      MA013: 'MA013',
    },
  ];

  const opArticleNumber = () => {
    // router.push('/numberConfiguration')
  };

  /**
   * @exports searchConfig 搜索栏配置表
   */
  const searchConfig = [
    {
      label: '公司名称',
      key: 'COMPANY',
      placeholder: '请输入公司名称',
      value: null,
    },
    {
      label: '创建人',
      key: 'CREATOR',
      placeholder: '请输入创建人',
      value: null,
    },
    {
      label: '供应商ID',
      key: 'MA001',
      placeholder: '请输入供应商ID',
      value: null,
    },
    {
      label: '供应商名称',
      key: 'MA003',
      placeholder: '请输入供应商名称',
      value: null,
    },
    {
      label: '负责人',
      key: 'MA011',
      placeholder: '请输入供应商负责人',
      value: null,
    },
    {
      label: '负责人号码',
      key: 'MA011',
      placeholder: '请输入供应商负责人的手机号',
      value: null,
    },
  ];

  const columnsConfig = [
    {
      title: '公司',
      dataIndex: 'COMPANY',
      checked: true,
    },
    {
      title: '创建者',
      dataIndex: 'CREATOR',
      checked: true,
    },
    {
      title: '供应商编码',
      dataIndex: 'MA001',
      checked: true,
    },
    {
      title: '供应商简称',
      dataIndex: 'MA002',
      checked: true,
    },
    {
      title: '供应商名称',
      dataIndex: 'MA003',
      checked: true,
    },
    {
      title: '供应商邮箱',
      dataIndex: 'MA011',
      checked: true,
    },
    {
      title: '供应商负责人',
      dataIndex: 'MA012',
      checked: true,
    },
    {
      title: '供应商负责人电话',
      dataIndex: 'MA013',
      checked: true,
    },
    {
      title: '操作',
      slotName: 'option',
      checked: true,
    },
  ];

  const config = ['add', 'Download', 'derive'];

  /**
   * @exports init 初始化
   */
  const init = () => {
    base.searchConfig = searchConfig;
    base.columns = columnsConfig;
    base.config = config;
    base.loading = false;
  };

  /**
   * @exports tapDate 触发搜索
   * @param param
   */
  const tapDate = (param) => {
    // console.log(param, '==>tapDate')
    // console.log(getInitParam(queryDataFilter(param)), '==>tapDate')
  };

  /**
   * @exports handlePageChange 页码变化时
   */
  const handlePageChange = (page: number) => {
    base.pagination.current = page;
    init();
  };
  const handlePageSizeChange = (pageSize: number) => {
    base.pagination.pageSize = pageSize;
    init();
  };

  return {
    base,
    opArticleNumber,
    data,
    init,
    tapDate,
    handlePageChange,
    handlePageSizeChange,
  };
}
